#include "readercenter.h"
#include "ui_readercenter.h"

ReaderCenter::ReaderCenter(void(*func)(void *),void *obj, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ReaderCenter)
{
    ui->setupUi(this);
    lp = func;
    lpobj = obj;

    ui->btn_bbook->setStyleSheet(
                "QPushButton{"
                "color: rgb(0, 0, 0);"
                "border:2px groove gray;"
                "border-color: rgb(0, 0, 0);"
                "border-radius:10px;"
                "background-color: rgba(20,196,188, 210);"
                "font:28px '宋体';}"
  "QPushButton::hover{"
                "border:2px groove gray;"
                "border-color: rgb(255, 255, 255);"
                "background-color: rgba(251,102,102, 200);"
                "color:rgb(255,255,255);}"
   "QPushButton::pressed{"
                "color: rgb(255, 0, 0);"
                "border:2px groove gray;"
                "border-color: rgb(255, 0, 0);"
                "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(20,196,188, 210), stop:1 rgba(251,102,102, 200));}");

   ui->btn_rbook->setStyleSheet(
               "QPushButton{"
               "color: rgb(0, 0, 0);"
               "border:2px groove gray;"
               "border-color: rgb(0, 0, 0);"
               "border-radius:10px;"
               "background-color: rgba(20,196,188, 210);"
               "font:28px '宋体';}"
 "QPushButton::hover{"
               "border:2px groove gray;"
               "border-color: rgb(255, 255, 255);"
               "background-color: rgba(251,102,102, 200);"
               "color:rgb(255,255,255);}"
  "QPushButton::pressed{"
               "color: rgb(255, 0, 0);"
               "border:2px groove gray;"
               "border-color: rgb(255, 0, 0);"
               "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(20,196,188, 210), stop:1 rgba(251,102,102, 200));}");

  ui->btn_logout->setStyleSheet(
              "QPushButton{"
              "color: rgb(0, 0, 0);"
              "border:2px groove gray;"
              "border-color: rgb(0, 0, 0);"
              "border-radius:10px;"
              "background-color: rgba(20,196,188, 210);"
              "font:28px '宋体';}"
"QPushButton::hover{"
              "border:2px groove gray;"
              "border-color: rgb(255, 255, 255);"
              "background-color: rgba(251,102,102, 200);"
              "color:rgb(255,255,255);}"
 "QPushButton::pressed{"
              "color: rgb(255, 0, 0);"
              "border:2px groove gray;"
              "border-color: rgb(255, 0, 0);"
              "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(20,196,188, 210), stop:1 rgba(251,102,102, 200));}");


  ui->btn_personal->setStyleSheet(
              "QPushButton{"
              "color: rgb(0, 0, 0);"
              "border:2px groove gray;"
              "border-color: rgb(0, 0, 0);"
              "border-radius:10px;"
              "background-color: rgba(20,196,188, 210);"
              "font:28px '宋体';}"
"QPushButton::hover{"
              "border:2px groove gray;"
              "border-color: rgb(255, 255, 255);"
              "background-color: rgba(251,102,102, 200);"
              "color:rgb(255,255,255);}"
 "QPushButton::pressed{"
              "color: rgb(255, 0, 0);"
              "border:2px groove gray;"
              "border-color: rgb(255, 0, 0);"
              "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(20,196,188, 210), stop:1 rgba(251,102,102, 200));}");



}

ReaderCenter::~ReaderCenter()
{
    delete ui;
}

void ReaderCenter::notify()
{
    QMyPageWidget* widget = (QMyPageWidget*)ui->stackedWidget->currentWidget();
    widget->notify();
}

void ReaderCenter::on_btn_personal_clicked()
{
    ui->stackedWidget->setCurrentIndex(0);
    notify();
}

void ReaderCenter::on_btn_bbook_clicked()
{
    ui->stackedWidget->setCurrentIndex(1);
    notify();
}

void ReaderCenter::on_btn_rbook_clicked()
{
    ui->stackedWidget->setCurrentIndex(2);
    notify();
}

void ReaderCenter::on_btn_logout_clicked()
{
    this->lp(lpobj);
    this->close();
}
